﻿using System;
using UnityEngine;

namespace Studio
{
	// Token: 0x02000498 RID: 1176
	public class OCILight : ObjectCtrlInfo
	{
		// Token: 0x17000310 RID: 784
		// (get) Token: 0x06001D58 RID: 7512 RVA: 0x000BAC5C File Offset: 0x000B8E5C
		public OILightInfo lightInfo
		{
			get
			{
				return this.objectInfo as OILightInfo;
			}
		}

		// Token: 0x17000311 RID: 785
		// (get) Token: 0x06001D59 RID: 7513 RVA: 0x000BAC6C File Offset: 0x000B8E6C
		public Light light
		{
			get
			{
				if (this.m_Light == null)
				{
					this.m_Light = this.objectLight.GetComponentInChildren<Light>();
				}
				return this.m_Light;
			}
		}

		// Token: 0x17000312 RID: 786
		// (get) Token: 0x06001D5A RID: 7514 RVA: 0x000BAC98 File Offset: 0x000B8E98
		public LightType lightType
		{
			get
			{
				return (!(this.light != null)) ? LightType.Directional : this.light.type;
			}
		}

		// Token: 0x06001D5B RID: 7515 RVA: 0x000BACBC File Offset: 0x000B8EBC
		public void SetColor(Color _color)
		{
			this.lightInfo.color = _color;
			this.light.color = this.lightInfo.color;
			if (this.lightColor)
			{
				this.lightColor.color = this.lightInfo.color;
			}
		}

		// Token: 0x06001D5C RID: 7516 RVA: 0x000BAD14 File Offset: 0x000B8F14
		public bool SetIntensity(float _value, bool _force = false)
		{
			if (!Utility.SetStruct<float>(ref this.lightInfo.intensity, _value) && !_force)
			{
				return false;
			}
			if (this.light)
			{
				this.light.intensity = this.lightInfo.intensity;
			}
			return true;
		}

		// Token: 0x06001D5D RID: 7517 RVA: 0x000BAD68 File Offset: 0x000B8F68
		public bool SetRange(float _value, bool _force = false)
		{
			if (!Utility.SetStruct<float>(ref this.lightInfo.range, _value) && !_force)
			{
				return false;
			}
			if (this.light)
			{
				this.light.range = this.lightInfo.range;
			}
			return true;
		}

		// Token: 0x06001D5E RID: 7518 RVA: 0x000BADBC File Offset: 0x000B8FBC
		public bool SetSpotAngle(float _value, bool _force = false)
		{
			if (!Utility.SetStruct<float>(ref this.lightInfo.spotAngle, _value) && !_force)
			{
				return false;
			}
			if (this.light)
			{
				this.light.spotAngle = this.lightInfo.spotAngle;
			}
			return true;
		}

		// Token: 0x06001D5F RID: 7519 RVA: 0x000BAE10 File Offset: 0x000B9010
		public bool SetEnable(bool _value, bool _force = false)
		{
			if (!Utility.SetStruct<bool>(ref this.lightInfo.enable, _value) && !_force)
			{
				return false;
			}
			if (this.light)
			{
				this.light.enabled = this.lightInfo.enable;
			}
			return true;
		}

		// Token: 0x06001D60 RID: 7520 RVA: 0x000BAE64 File Offset: 0x000B9064
		public bool SetDrawTarget(bool _value, bool _force = false)
		{
			if (!Utility.SetStruct<bool>(ref this.lightInfo.drawTarget, _value) && !_force)
			{
				return false;
			}
			Singleton<GuideObjectManager>.Instance.drawLightLine.SetEnable(this.light, this.lightInfo.drawTarget);
			this.guideObject.visible = this.lightInfo.drawTarget;
			return true;
		}

		// Token: 0x06001D61 RID: 7521 RVA: 0x000BAEC8 File Offset: 0x000B90C8
		public bool SetShadow(bool _value, bool _force = false)
		{
			if (!Utility.SetStruct<bool>(ref this.lightInfo.shadow, _value) && !_force)
			{
				return false;
			}
			if (this.light)
			{
				this.light.shadows = ((!this.lightInfo.shadow) ? LightShadows.None : LightShadows.Soft);
			}
			return true;
		}

		// Token: 0x06001D62 RID: 7522 RVA: 0x000BAF28 File Offset: 0x000B9128
		public void Update()
		{
			this.SetColor(this.lightInfo.color);
			this.SetIntensity(this.lightInfo.intensity, true);
			this.SetRange(this.lightInfo.range, true);
			this.SetSpotAngle(this.lightInfo.spotAngle, true);
			this.SetEnable(this.lightInfo.enable, true);
			this.SetDrawTarget(this.lightInfo.drawTarget, true);
			this.SetShadow(this.lightInfo.shadow, true);
		}

		// Token: 0x06001D63 RID: 7523 RVA: 0x000BAFB8 File Offset: 0x000B91B8
		public override void OnDelete()
		{
			Singleton<GuideObjectManager>.Instance.Delete(this.guideObject, true);
			UnityEngine.Object.Destroy(this.objectLight);
			if (this.parentInfo != null)
			{
				this.parentInfo.OnDetachChild(this);
			}
			Studio.DeleteInfo(this.objectInfo, true);
		}

		// Token: 0x06001D64 RID: 7524 RVA: 0x000BB004 File Offset: 0x000B9204
		public override void OnAttach(TreeNodeObject _parent, ObjectCtrlInfo _child)
		{
		}

		// Token: 0x06001D65 RID: 7525 RVA: 0x000BB008 File Offset: 0x000B9208
		public override void OnLoadAttach(TreeNodeObject _parent, ObjectCtrlInfo _child)
		{
		}

		// Token: 0x06001D66 RID: 7526 RVA: 0x000BB00C File Offset: 0x000B920C
		public override void OnDetach()
		{
			this.parentInfo.OnDetachChild(this);
			this.guideObject.parent = null;
			Studio.AddInfo(this.objectInfo, this);
			this.objectLight.transform.SetParent(Singleton<Scene>.Instance.commonSpace.transform);
			this.objectInfo.changeAmount.pos = this.objectLight.transform.localPosition;
			this.objectInfo.changeAmount.rot = this.objectLight.transform.localEulerAngles;
		}

		// Token: 0x06001D67 RID: 7527 RVA: 0x000BB09C File Offset: 0x000B929C
		public override void OnDetachChild(ObjectCtrlInfo _child)
		{
		}

		// Token: 0x06001D68 RID: 7528 RVA: 0x000BB0A0 File Offset: 0x000B92A0
		public override void OnSelect(bool _select)
		{
		}

		// Token: 0x06001D69 RID: 7529 RVA: 0x000BB0A4 File Offset: 0x000B92A4
		public override void OnSavePreprocessing()
		{
			base.OnSavePreprocessing();
		}

		// Token: 0x06001D6A RID: 7530 RVA: 0x000BB0AC File Offset: 0x000B92AC
		public override void OnVisible(bool _visible)
		{
		}

		// Token: 0x04001FC0 RID: 8128
		public GameObject objectLight;

		// Token: 0x04001FC1 RID: 8129
		protected Light m_Light;

		// Token: 0x04001FC2 RID: 8130
		public Info.LightLoadInfo.Target lightTarget;

		// Token: 0x04001FC3 RID: 8131
		public LightColor lightColor;
	}
}
